package cn.git.led.test;

import java.util.Calendar;

import cn.git.led.utils.SetSystemTime;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;

/**
 * 运行方法
 *	码云颜色对应标识
 *	less == 0     0
 *  little < 8    1
 *	some < 15     8
 *	many <= 23    16
 *	much > 23     24
 */
public class Init {

	public static void main(String[] args) throws Exception{


		//码云LED开始时间
		DateTime start_date= DateUtil.parseDate("2022/05/09");
		String start_time= "10:43:00";

		//获取二维码

		// 猫咪
		int [] [] Led= {
				{0,0,0,0,24,0,0,0,0,24,0,0,0,0,0,24,24,24,24,24,24,24,0,0,0,0,24,24,24,24,24,24,24,0,0,0,24,24,24,24,24,24,0,0,0,24,0,0,24,0,0,0,0,0},
				{0,0,0,24,1,24,24,24,24,1,24,0,0,0,24,16,8,8,1,8,8,16,24,0,0,24,8,8,1,1,1,8,8,24,0,0,24,16,16,16,16,24,0,0,24,24,24,24,24,24,0,0,0,0},
				{0,0,0,24,1,1,1,1,1,1,24,0,0,0,24,8,8,1,1,1,8,8,24,0,24,16,8,8,1,1,1,8,8,16,24,0,24,1,16,16,1,24,0,0,24,1,16,16,1,24,0,0,0,0},
				{0,8,8,24,1,24,1,1,24,1,24,8,8,0,24,16,24,24,24,24,24,16,24,0,24,16,16,24,24,24,24,24,16,16,24,0,24,16,16,16,16,24,0,0,24,24,24,24,24,24,0,0,0,0},
				{0,0,0,24,1,1,16,16,1,1,24,0,0,0,24,24,1,24,1,24,1,24,24,0,0,24,24,1,24,1,24,1,24,24,0,0,24,24,24,24,24,24,0,24,0,0,24,24,0,0,0,0,0,0},
				{0,8,8,24,1,1,1,1,1,1,24,8,8,0,0,24,1,1,1,1,1,24,0,0,0,0,24,1,1,1,1,1,24,0,0,0,0,0,24,24,0,0,0,0,24,24,24,24,24,0,0,0,0,0},
				{0,0,0,0,24,24,24,24,24,24,0,0,0,0,0,0,24,24,24,24,24,0,0,0,0,0,0,24,24,24,24,24,0,0,0,0,24,24,24,24,24,24,0,0,0,0,24,24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0,24,24,0,0,24,24,24,24,24,0,0,24,24},
//				{0,0,0,0,0,0,8,8,8,8,0,0,0,0,0,8,0,0,0,8,8,0,0,0,0,0,0,0,0,0,8,8,8,8,8,8,0,24,0,0,0,24,24,0,0,24,24,24,24,24,0,0,24,24},
//				{0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,8,8,8,0,0,0,8,0,0,0,24,24,0,24,24,24,24,24,24,24,0,24,24},
//				{0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,8,0,0,0,8,8,0,0,0,0,0,0,0,0,0,0,8,8,8,0,0,0,8,0,0,0,24,24,0,0,24,24,24,24,24,0,0,24,24},
//				{0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,8,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,8,8,8,0,0,0,8,0,0,0,24,24,0,0,24,24,24,24,24,24,0,24,24},
//				{0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,8,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,8,8,8,0,0,0,8,0,0,0,24,24,0,24,24,0,0,0,24,24,0,24,24}
//		};

		//设置系统时间
		Boolean settime = SetSystemTime.setDateTimeBat(start_time, start_date.toDateStr());
		System.out.println("设置系统时间>"+settime);
		Thread.sleep(500L);
		int daynum=0;
		for (int i = 0; i < Led[0].length; i++) {

			for (int j = 0; j <Led.length; j++) {

				//提交次数
				int submitNum=Led[j][i];
				int jsq=0;

				for (int j2 = 0; j2 <submitNum; j2++) {
					//git提交
					Boolean boolean1= GitUtil.commitFiles();
					//判断还在提交，如果没结束，等待提交
					do {
						try {
							Thread.sleep(500L);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						System.err.println("等待提交");
						boolean1=true;
					} while (boolean1==false);
					jsq++;

				}
				System.out.print(DateUtil.now()+">>执行第"+jsq+"次");
				//设置时间累加
				daynum++;
				Calendar calendar=Calendar.getInstance();
				calendar.setTime(start_date);
				calendar.add(Calendar.DATE, daynum);
				//设置系统时间
				String format = DateUtil.format(calendar.getTime(), "yyyy/MM/dd");
				System.out.println(format);
				String formatTime = DateUtil.formatTime(DateUtil.date());

				// 如果要刷当天把这里注释掉
				boolean settime2 = SetSystemTime.setDateTimeBat(formatTime, format);
				System.out.println("下一个时间:"+DateUtil.formatDate(calendar.getTime())+"设置成功"+settime2);
				System.out.println();
			}
		}
		System.out.println(">>完成");
	}


}
